<template>
<!--用户的个人信息页面-->
  <el-card style="width: 500px">
    <el-form title="管理员信息" ref="form" :model="form" size="small" label-width="80px">
      <el-form-item label="用户名" autocapitalize="off">
        <el-input v-model="form.username"></el-input>
      </el-form-item>
      <el-form-item label="昵称" autocapitalize="off">
        <el-input v-model="form.nickname"></el-input>
      </el-form-item>
      <el-form-item label="头像" autocapitalize="off">
        <el-input v-model="form.avatar"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="save">确定</el-button>
      </el-form-item>
    </el-form>

  </el-card>
</template>

<script>
import axios from "axios";
export default {
  name: "person",
  data() {
    return {
      form: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {nickname: '管理员'}
    }
  },
  methods:{
    save() {
      this.request.post("/admin/updateAdmin", this.form).then( res => {
        // console.log(res)
        if (res.state === 200 ){
          this.$message.success("修改成功")
          this.$router.push('/');
        }else {
          this.$message.error("修改失败,"+res.message)
        }
      })

    }
  }
}
</script>

<style scoped>

</style>